package org.csc.sss.core.config;

import org.csc.sss.core.model.SysUser;
import org.springframework.data.domain.AuditorAware;
import org.springframework.security.core.context.SecurityContextHolder;

public class MyAuditorAware implements AuditorAware<SysUser> {

    @Override
    public SysUser getCurrentAuditor() {
        if (SecurityContextHolder.getContext().getAuthentication().getPrincipal() instanceof SysUser) {
            return (SysUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        }
        return null;
    }
}
